#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e6+10;
int prime[maxn], v[maxn];
int m = 0;
void primes(int n){
    for(int i=2; i<=n; ++i){
        if(v[i]==0){
            v[i] = i;
            prime[++m] = i;
        }
        for(int j=1; j<=m; ++j){
            if(prime[j] > v[i] || prime[j] > n/i) break;
            v[i*prime[j]] = prime[j];
        }
    }
}

int gcd(int a, int b){
    return b==0? a: gcd(b, a%b);
}


int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int T; cin >> T;
    primes(maxn);
    while (T--){
        int N; cin >> N;
        string s; cin >> s;
        map<char, int> cnt;
        for(auto c:s) cnt[c]++;
        int a = 0, g = 0;
        for(auto c:cnt){
            if(!a) a = c.second;
            else{
                g = gcd(a, c.second);
            }
        }
        if(!g) g = a;
        if(g==1) {cout << "No\n"; continue;}
        vector<int> yue;
        for (int i = 1; i*i<=g ; ++i) {
            if(g%i==0){
                yue.push_back(i);
                if(g/i!=i) yue.push_back(g/i);
            }
        }
        bool can = false;
        for(auto k:yue)if(k>1){
            int len = N/k;
            int p = 0;
            bool flg = true;
            while (true){
                map<char, int> cn;
                for(int i=p; i<p+len; ++i) cn[s[i]]++;
                for(auto c:cn){
                    char aa = c.first;
                    if(cnt[aa] % cn[aa] == 0)continue;
                    else {flg = false; break;}
                }
                if(!flg) break;
                p+=len;
                if(p > N-1) break;
            }
            if(!flg) continue;

            unordered_set<string> loop;
            string ss = s.substr(0, len);
            loop.insert(ss);
            for (int i = 1; i < len; ++i) {
                ss.push_back(ss[0]);
                ss.erase(ss.begin());
                loop.insert(ss);
            }

            p = len;
            flg = true;
            while (p<=N-1){
                if (!loop.count(s.substr(p, len))) {flg = false; break;}
                p+=len;
            }
            if(!flg) continue;
            can = true; break;
        }
        if(!can) cout << "No\n";
        else cout << "Yes\n";

    }
    return 0;
}